﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Manage_news_CreateNews :System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            initData();
        }
    }
    public void initData()
    {
        BLL.Information info = new BLL.Information();
        string id =J.Comm.Url.Output(Request["id"]);
        if (!string.IsNullOrEmpty(id))
        {
            DataView dv = info.Find(0, id).Tables[0].DefaultView;
            if (dv.Table.Rows.Count > 0)
            {
                sTitle.Text = dv.Table.Rows[0]["sTitle"].ToString();
                sFrom.Text = dv.Table.Rows[0]["sFrom"].ToString();
                sLink.Text = dv.Table.Rows[0]["sLink"].ToString();
                sTag.Text = dv.Table.Rows[0]["sTag"].ToString();
                sAuthor.Text = dv.Table.Rows[0]["sAuthor"].ToString();
                sText.Value = dv.Table.Rows[0]["sText"].ToString();
            }
        }
    }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        BLL.Model.MInformation minfo = new BLL.Model.MInformation();
        minfo.sTitle = sTitle.Text;
        minfo.nKey = Convert.ToInt32(J.Comm.Url.Output(Request["nKey"]));
        minfo.sTag = sTag.Text;
        minfo.sFrom = sFrom.Text;
        minfo.sLink = sLink.Text;
        minfo.sText = sText.Value;
        minfo.sAuthor = sAuthor.Text;
        if(!String.IsNullOrEmpty(J.Comm.Url.Output(Request["id"])))
            minfo.WorkType=(int)BLL.WorkType.Update;
        else
            minfo.WorkType = (int)BLL.WorkType.Insert;
        BLL.Information info = new BLL.Information();
        info.DoWork(minfo);

        J.Comm.Url.ShowAndRedirect(this.Page, "保存成功！", "infolist.aspx?nkey=" + J.Comm.Url.Output(Request["nKey"]) + "&name=" + J.Comm.Url.Output(Request["name"]) + "&mm_name=" + J.Comm.Url.Output(Request["mm_name"]));
    }
}
